package org.ihelpuoo.orm.filter;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Iterator;

import org.ihelpuoo.lang.LoaderException;
import org.ihelpuoo.lang.RenderException;
import org.ihelpuoo.parser.AbstractTextEngine;
import org.ihelpuoo.parser.segment.Segment;

public abstract class SegmentFilter extends AbstractTextEngine
		implements
		Segment,
		Filter
{
	private Segment	seg;

	public SegmentFilter(Segment seg)
	{
		this.seg = seg;
	}

	public String getString()
	{
		return seg.toString();
	}

	public void parse(Reader r) throws LoaderException
	{
		seg.parse(r);
	}

	public void clearAll()
	{
		seg.clearAll();
	}

	public Segment duplicate()
	{
		return seg.duplicate();
	}

	public Iterator<String> iterator()
	{
		return seg.iterator();
	}

	public Segment set(String key, boolean v)
	{
		return seg.set(key,v);
	}

	public Segment set(String key, byte v)
	{
		return seg.set(key,v);
	}

	public Segment set(String key, double v)
	{
		return seg.set(key,v);
	}

	public Segment set(String key, float v)
	{
		return seg.set(key,v);
	}

	public Segment set(String key, int v)
	{
		return seg.set(key,v);
	}

	public Segment set(String key, long v)
	{
		return seg.set(key,v);
	}

	public Segment set(String key, Object v)
	{
		return seg.set(key,v);
	}

	public Segment set(String key, short v)
	{
		return seg.set(key,v);
	}

	public int size()
	{
		return seg.size();
	}

	public boolean isEquals(Segment seg)
	{
		return seg.isEquals(seg);
	}

	public Segment add(String key, Object v)
	{
		return seg.add(key,v);
	}

	public String getOriginContent()
	{
		return seg.getOriginContent();
	}

	@Override
	public String toString()
	{
		return seg.render().toString();
	}

	public void render2(Writer w) throws RenderException
	{
		try
		{
			w.append(seg.render());
		}
		catch (IOException e)
		{
			throw new RenderException(e);
		}
	}

	public CharSequence render()
	{
		return seg.render();
	}
	
	public boolean contains(String key)
	{
		return seg.contains(key);
	}

}
